﻿using System;
using System.Collections.Generic;
using example;

namespace host
{
    internal class Program
    {
        private static void Main(string[] args) {
            var producer = new Producer();
            var consumer = new consumer(new SubConsumer());
            var mainboard = new mainboard(producer, consumer);

            mainboard.output += Console.WriteLine;
            mainboard.input("Paul");

            var a = new A();
            var b = new B();
            var c = new C();
            var splitAndJoin = new SplitAndJoin(a, b, c);
            var result = "";
            splitAndJoin.Output += Console.WriteLine;
            splitAndJoin.Input("Jakob");
        }
    }

    internal class C : IC
    {
        public event Action<string> Output;

        public void Input(Tuple<string, string> message) {
            Output("C: " + message.Item1 + "/" + message.Item2);
        }
    }

    internal class A : IA
    {
        public event Action<string> Output;

        public void Input(string message) {
            Output("A: " + message);
        }
    }

    internal class B : IB
    {
        public event Action<string> Output;

        public void Input(string message) {
            Output("B: " + message);
        }
    }

    internal class Producer : IProducer
    {
        public event Action<IList<string>> output;

        public void input(string message) {
            output(new[] {"Producer (" + message + ")"});
        }
    }

    internal class SubConsumer : ISubconsumer
    {
        public event Action<string> output;

        public void input(IList<string> messages) {
            output("SubConsumer (" + string.Join(", ", messages) + ")");
        }
    }
}